home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / batches / merge.bat < prev    next >
DOS Batch File  |  1993-08-02  |  3KB  |  97 lines

  1. @echo off
  2. !   merge.bat     merges files with the same name and different extensions
  3. !
  4. !   This program accepts extensions as input arguments and merges the files
  5. !   into single files with another extension.
  6. !
  7. !   Format:  MERGE dst src1 src2 src3 src4 src5
  8. !
  9. !   Where:   dst  = extension of the result
  10. !            srcN = extensions of the files to be merged
  11. !
  12. !   Example: MERGE COMB HEAD BODY TAIL
  13. !
  14. !            in a directory containing A.COMB, A.HEAD, A.BODY, BBBODY, C.BODY, C.TAIL
  15. !            produces the following files (where '+' indicates concatenation):
  16. !
  17. !            A.COMB = A.COMB + A.HEAD + A.BODY
  18. !            BBCOMB = BBBODY
  19. !            C.COMB = C.BODY + C.TAIL
  20. !
  21. !   DOS would have achieved a similar result with the command:
  22. !
  23. !            COPY *.HEAD + *.BODY + *.TAIL *.COMB
  24. !
  25. !   with the difference that A.COMB would have been replaced by A.HEAD + A.BODY
  26. !   rather than by A.COMB + A.HEAD + A.BODY. Also, with DOS you would have not been able to
  27. !   pick up BBBODY because it does not have a "dotted" extension.
  28. !
  29. !   Note that merge.bat uses INCR and DECR, which are case sensitive, and FOR, which capitalises
  30. !   the filenames. Therefore, you must type the extensions in upper case, otherwise INCR and
  31. !   DECR will not work.
  32. !
  33. !   Copyright © 1993 by Rainbow Hill Pty Ltd. All rights reserved.
  34. !
  35.  
  36.     !                              the first two arguments are mandatory
  37.     if "%1 " == " " goto WRONG_LBL
  38.     if " %1" == " /?" goto HELP_LBL
  39.     if "%2 " == " " goto WRONG_LBL
  40.     onerror ERR_LBL
  41.  
  42.     for %filename in (*%2) do begin
  43.         set f=%filename%A
  44.         decr f by %2A
  45.         incr f by %1A
  46.         decr f by 1
  47.         copy %filename% %f% /A
  48.     next filename
  49.  
  50.     if "%3 " == " " goto DONE_LBL
  51.     for %filename in (*%3) do begin
  52.         set f=%filename%A
  53.         decr f by %3A
  54.         incr f by %1A
  55.         decr f by 1
  56.         copy %filename% %f% /A
  57.     next filename
  58.  
  59.     if "%4 " == " " goto DONE_LBL
  60.     for %filename in (*%4) do begin
  61.         set f=%filename%A
  62.         decr f by %4A
  63.         incr f by %1A
  64.         decr f by 1
  65.         copy %filename% %f% /A
  66.     next filename
  67.  
  68.     if "%5 " == " " goto DONE_LBL
  69.     for %filename in (*%5) do begin
  70.         set f=%filename%A
  71.         decr f by %5A
  72.         incr f by %1A
  73.         decr f by 1
  74.         copy %filename% %f% /A
  75.     next filename
  76.  
  77.     goto DONE_LBL
  78.  
  79. :WRONG_LBL
  80.     echo ***ERROR: less than two arguments.
  81.     echo.
  82.  
  83. :HELP_LBL
  84.     echo Merges files with the same name and different extensions
  85.     echo.
  86.     echo    MERGE dst src1 [src2 [src3 [src4 [src5]]]]
  87.     echo.
  88.     echo    dst  = extension of the result
  89.     echo    srcN = extensions of the files to be merged
  90.     echo.
  91.     goto DONE_LBL
  92.  
  93. :ERR_LBL
  94.     show %doserr%
  95.  
  96. :DONE_LBL
  97.